About 973 letters

About 5 minutes

#compile

Description: Compiles source into a code or AST object. The resulting code object can be executed by exec or eval.

def compile(source, filename, mode, flags=0, dont_inherit=False, optimize=-1): ''' Compiles source into a code or AST object :param source: A string, bytes, or an AST object :param filename: Filename or '<string>' :param mode: 'exec', 'eval', or 'single' :param flags: Flags :param dont_inherit: Whether to inherit :param optimize: Optimization level :return: A code or AST object '''

Example:

print(compile("print('hello')", "<string>", "eval")) print(compile("", __file__, "exec"))

>>> Establishing WebAssembly Runtime.

>>> Standby.

Powered by Shift.

Created in 6/9/2025

Updated in 6/9/2025